package Frame.sayoptional;

import FCRendering.FCRMaster;
import VWorldGameStudio.FCPlayerInfo;
import Function.FCMutilPlayCache;

import static FCRendering.FCRMaster.*;

public class NpcJoinTypeOptional implements ISayoption{
    @Override
    public void clickWhichOption(SayTextAndOption op) {
            FCPlayerInfo npc = new FCPlayerInfo();
            npc.setName(fcv.getSayNpcName());
            npc.setSelectPlayer(2);
            if(op.getParam() != null){
                //选择职业的
                npc.setSelectPlayer(Integer.parseInt(op.getParam()));
            }
            npc.setANpcPlayer(true);
            //TODO 然后呢，属性参数哪些用表格来配吧
            FCMutilPlayCache.joinGame(npc);
            if (FCRMaster.player1.joinInTeam(npc)) {
                //TODO 加入队伍后，这个npc要永远消失的
                if (fcv.getOtherEventKey() != null) {
                    gameSave.getOtherEventMaps().put(fcv.getOtherEventKey(), fcv.getSayNpcName());
                }
                fcv.getMessage().add(langLib.getNameOfId(fcv.getSayNpcName())+": "+langLib.getNameOfId(op.optionTextRepoId));
                fcv.showMessage();
            } else {
                fcv.getMessage().add(langLib.getNameOfId(fcv.getSayNpcName())+":你的队伍里满人了，请离一个吧! ");
                fcv.showMessage();
            }
            fcv.setOtherEventKey(null);
        fcv.setOpenSay(false);
        fcv.setSayText(null);
        fcv.setSayNpcName(null);
    }
}
